/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package slideshow;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 *
 * @author Andrea
 */
public class NextImage implements ActionListener {

    private MainPanel lmwMainPanel;
    private MainWindow lmwMainWindow;
    
    public NextImage ( MainPanel amwMainPanel, MainWindow amwMainWindow ) {
        
        this.lmwMainPanel = amwMainPanel;
        this.lmwMainWindow = amwMainWindow;
        
    }
    
    @Override
    public void actionPerformed ( ActionEvent e ) {
        
        lmwMainPanel.lipzImagePanel.fnSetImage ( 
                
                lmwMainPanel.llListImages.fnGetImageAtIndexOf ( lmwMainPanel.liIndex ++ ) );
        
        if ( lmwMainPanel.liIndex == ( lmwMainPanel.llListImages.fnGetNumerOfListItems() -1 ) ) {
            
            lmwMainPanel.lbButtonNext.setEnabled ( false );
            
        }
        
        else {
            
            lmwMainPanel.lbButtonNext.setEnabled ( true );
            lmwMainPanel.lbButtonPrevious.setEnabled ( true );
            
        } 
        
        lmwMainWindow.repaint();
    
    }
    
}
